package com.tianhua.javs.core.parse;

import com.tianhua.javs.client.bean.JavsDocBean;
import com.tianhua.javs.core.constant.TagConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Description:带有注释标示符号的脚本行解析
 * date: 2022/2/16
 *
 * @author shenshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Service
public class DocParseService {


    @Autowired
    private SegmentSpreadParseService segmentSpreadParseService;

    /**
     * 单行注释内容
     * @param rowSegment
     * @return
     */
    public JavsDocBean parseJavsDoc(String rowSegment){
        JavsDocBean javsDocBean = new JavsDocBean();
        if(rowSegment.trim().startsWith(TagConstants.DOC_JING) || rowSegment.trim().startsWith(TagConstants.DOC_LINE)){
            javsDocBean.setDocRow(true);
            rowSegment = rowSegment.replace(TagConstants.DOC_JING,"").replace(TagConstants.DOC_LINE,"");
            javsDocBean.setRowSegment(rowSegment);
            String blankPreffix = segmentSpreadParseService.getBlankPrefix(rowSegment);
            javsDocBean.setBlankPreffix(blankPreffix);
            return javsDocBean;
        }
        javsDocBean.setRowSegment(rowSegment);
        return javsDocBean;

    }

}
